/* Copyright 2005-2006 Tim Fennell
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.sourceforge.stripes.validation;

/**
 * <p>Interface to be implemented by ActionBeans which need to perform some level of validation above
 * and beyond what Stripes can do through Annotations.  Allows for a clean separation of validation
 * logic and regular business logic.  This is especially useful since an ActionBean can have
 * multiple handler methods each responsible for handling a different event.</p>
 *
 * <p>By the time the validate() method is invoked Stripes has already performed all Annotated
 * validations and has converted and bound properties from the HttpServletRequest on to the
 * ActionBean.</p>
 *
 * <p>The default behaviour is Stripes is such that if validation errors arise from the annotated
 * validations (or type conversion), the validate() method will not be called (nor will the handler
 * method). This behaviour is configurable though.  Please see the Stripes documentation on
 * <a href="http://stripes.mc4j.org/confluence/display/stripes/Configuration+Reference">Configuration</a>
 * if you would prefer to have validate() called even when validation errors
 * have been generated by type conversion and annotation based validation.</p>
 *
 * @author Tim Fennell
 * @deprecated Beginning with Stripes 1.3 the preferred way to add custom validation logic to
 *             an ActionBean is with {@link ValidationMethod}. The Validatable interface will be
 *             removed in a future release. Converting is as easy as removing
 *             "implements Validatable" from your class and adding {@literal @ValidationMethod}
 *             to your validate() method.
 */
@Deprecated
public interface Validatable {

    /**
     * Internal validation of ActionBean state before invocation of a handler method should occur
     * here.  ActionBeans are free to do as they please, and have full access to the
     * ActionBeanContext in order to validate themselves.
     *
     * @param errors a ValidationErrors object to which errors should be added
     */
    void validate(ValidationErrors errors);
}
